package com.kakarote.crm9.erp.jxc.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import com.kakarote.crm9.erp.jxc.entity.ProductCategoryEntity;
import com.kakarote.crm9.utils.R;

import java.util.List;

/**
 * @Author:Lzq
 * @Date:2021/3/16
 */
public class ProductCategoryService {
    //查询
    public List<Record> getProductCategoryList() {

        //查询
        List<Record> list = Db.find("select * from product_category");
        return list;
    }
    //新增
    public R insertCategory(String categoryName) {

        boolean flag = new ProductCategoryEntity().set("name", categoryName).save();
        if (flag) return R.ok();
        else return R.error();
    }

    //删除
    public R delCategory(Integer id) {

        boolean flag = ProductCategoryEntity.dao.deleteById(id);
        if (flag) return R.ok();
        else return R.error();
    }
}
